package com.TTBook.impl.book.daoImpl;

import com.TTBook.core.book.dao.BookInfoDAO;
import com.TTBook.core.book.model.BookInfo;
import com.TTBook.core.book.model.BookInfoCriteria;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BookInfoDAOImpl extends SqlMapClientDaoSupport implements BookInfoDAO {

    public BookInfoDAOImpl() {
        super();
    }

    public int countByCriteria(BookInfoCriteria criteria) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("ts_book_info.countByCriteria", criteria);
        return count.intValue();
    }

    public int deleteByCriteria(BookInfoCriteria criteria) {
        int rows = getSqlMapClientTemplate().delete("ts_book_info.deleteByCriteria", criteria);
        return rows;
    }

    public int deleteByPrimaryKey(String bookInfoId) {
        BookInfo key = new BookInfo();
        key.setBookInfoId(bookInfoId);
        int rows = getSqlMapClientTemplate().delete("ts_book_info.deleteByPrimaryKey", key);
        return rows;
    }

    public void insert(BookInfo record) {
        getSqlMapClientTemplate().insert("ts_book_info.insert", record);
    }

    public void insertSelective(BookInfo record) {
        getSqlMapClientTemplate().insert("ts_book_info.insertSelective", record);
    }

    public List selectByCriteria(BookInfoCriteria criteria) {
        List list = getSqlMapClientTemplate().queryForList("ts_book_info.selectByCriteria", criteria);
        return list;
    }

    public BookInfo selectByPrimaryKey(String bookInfoId) {
        BookInfo key = new BookInfo();
        key.setBookInfoId(bookInfoId);
        BookInfo record = (BookInfo) getSqlMapClientTemplate().queryForObject("ts_book_info.selectByPrimaryKey", key);
        return record;
    }

    public int updateByCriteriaSelective(BookInfo record, BookInfoCriteria criteria) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, criteria);
        int rows = getSqlMapClientTemplate().update("ts_book_info.updateByCriteriaSelective", parms);
        return rows;
    }

    public int updateByCriteria(BookInfo record, BookInfoCriteria example) {
        UpdateByCriteriaParms parms = new UpdateByCriteriaParms(record, example);
        int rows = getSqlMapClientTemplate().update("ts_book_info.updateByCriteria", parms);
        return rows;
    }

    public int updateByPrimaryKeySelective(BookInfo record) {
        int rows = getSqlMapClientTemplate().update("ts_book_info.updateByPrimaryKeySelective", record);
        return rows;
    }

    public int updateByPrimaryKey(BookInfo record) {
        int rows = getSqlMapClientTemplate().update("ts_book_info.updateByPrimaryKey", record);
        return rows;
    }

    private static class UpdateByCriteriaParms extends BookInfoCriteria {
        private Object record;

        public UpdateByCriteriaParms(Object record, BookInfoCriteria criteria) {
            super(criteria);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}